package praktikum4GastKomponente.Datentyp;

public class DGastEMail {

	private String email;

	public DGastEMail(String email) {
		if(!email.matches("[a-z]+@[a-z]+\\.[a-z]+")){
			throw new IllegalArgumentException("GastKomponente:DGastEMail: Die gegebene EMail ist ungueltig sie lautet: " + email);
		}
		
		this.email = email;
	}

	public String getEMail() {
		return email;
	}

	@Override
	public String toString() {
		return "DGastEMail [email=" + email + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		DGastEMail other = (DGastEMail) obj;
		if (email == null) {
			if (other.email != null) {
				return false;
			}
		} else if (!email.equals(other.email)) {
			return false;
		}
		return true;
	}
	
	
}
